package com.ruoyi.supply.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supply.domain.LocationInfo;
import com.ruoyi.supply.service.impl.LocationInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地点资讯Controller
 * 
 * @author Ryan
 * @date 2025-06-07
 */
@RestController
@RequestMapping("/supply/location")
@Api(tags = "地点资讯")
public class LocationInfoController extends BaseController
{
    @Autowired
    private LocationInfoService locationInfoService;

    /**
     * 查询地点资讯列表
     */
    @GetMapping("/list")
    @ApiOperation("查询地点资讯")
    public TableDataInfo list(LocationInfo locationInfo)
    {
        startPage();
        List<LocationInfo> list = locationInfoService.selectInfoList(locationInfo);
        return getDataTable(list);
    }

    /**
     * 导出地点资讯列表
     */
    @Log(title = "地点资讯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LocationInfo locationInfo)
    {
        List<LocationInfo> list = locationInfoService.selectInfoList(locationInfo);
        ExcelUtil<LocationInfo> util = new ExcelUtil<LocationInfo>(LocationInfo.class);
        util.exportExcel(response, list, "地点资讯数据");
    }

    /**
     * 获取地点资讯详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取地点资讯详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(locationInfoService.selectInfoById(id));
    }

    /**
     * 新增地点资讯
     */
    @Log(title = "地点资讯", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增地点资讯")
    public AjaxResult add(@RequestBody LocationInfo locationInfo)
    {
        return toAjax(locationInfoService.insertInfo(locationInfo));
    }

    /**
     * 修改地点资讯
     */
    @Log(title = "地点资讯", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改地点资讯")
    public AjaxResult edit(@RequestBody LocationInfo locationInfo)
    {
        return toAjax(locationInfoService.updateInfo(locationInfo));
    }

    /**
     * 删除地点资讯
     */
    @Log(title = "地点资讯", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除地点资讯")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(locationInfoService.deleteInfoByIds(ids));
    }

    @Log(title = "货源 资讯", businessType = BusinessType.DELETE)
    @PutMapping("/status/{id}/{status}")
    @ApiOperation("审核/驳回/下架")
    public AjaxResult aduit(@PathVariable Long id,@PathVariable String status){
        locationInfoService.statusChange(id,status);
        return AjaxResult.success();
    }
}
